package com.eee.xiang.market.dao.mapper;

import com.eee.xiang.market.beans.TOrder;
import com.eee.xiang.market.beans.TOrderExample;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

public interface TOrderMapper {
    long countByExample(TOrderExample example);

    int deleteByExample(TOrderExample example);

    int deleteByPrimaryKey(String orderId);

    int insert(TOrder record);

    int insertSelective(TOrder record);

    List<TOrder> selectByExample(TOrderExample example);

    TOrder selectByPrimaryKey(String orderId);

    int updateByExampleSelective(@Param("record") TOrder record, @Param("example") TOrderExample example);

    int updateByExample(@Param("record") TOrder record, @Param("example") TOrderExample example);

    int updateByPrimaryKeySelective(TOrder record);

    int updateByPrimaryKey(TOrder record);

    @Select("select * from t_order where staff_id = #{staffId}")
    List<TOrder> getAllOrderByStaffId(@Param("staffId") String staffId);

    List getAllOrderDetail();


    @Select("SELECT SUM(total_amount) AS total, DATE_FORMAT(create_datetime, '%Y-%m') AS month " +
            "FROM t_order GROUP BY DATE_FORMAT(create_datetime, '%Y-%m')")
    List<Map<String,Object>> orderListEchart();

    @Select("SELECT tem.*, cargo.cargo_name FROM t_cargo AS cargo RIGHT JOIN (SELECT cargo_id,SUM(amount) AS totalAmount,SUM(cargo_num) AS totalNum FROM `t_order_detail` GROUP BY cargo_id) AS tem ON tem.cargo_id = cargo.`cargo_id`")
    List<Map<String,Object>> orderDetailEchart();
}